package com.example.administrator.yuejian_2.adapter;

import android.content.Context;
<<<<<<< HEAD
import android.content.Intent;
=======
>>>>>>> b079ae49aea3652b48f9c84201c89333c2f216f2
import android.renderscript.Sampler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.yuejian_2.R;
<<<<<<< HEAD
import com.example.administrator.yuejian_2.activity.MaclassActivity;
=======
>>>>>>> b079ae49aea3652b48f9c84201c89333c2f216f2
import com.example.administrator.yuejian_2.bean.MasterCourseBean;
import com.example.administrator.yuejian_2.viewholder.MacourseVH;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/10/9.
 */

public class MacourseAdapter extends RecyclerView.Adapter {
    private List<MasterCourseBean> courseList = new ArrayList<>();
    private Context context;
    private LayoutInflater layoutInflater;

    public MacourseAdapter(Context context,List<MasterCourseBean> courseList){
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
        this.courseList.addAll(courseList);

    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_maclass,parent,false);
        MacourseVH holder = new MacourseVH(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MacourseVH courseholder =(MacourseVH) holder;
        MasterCourseBean courseBean = courseList.get(position);

<<<<<<< HEAD
        final String name = courseBean.getClass_name();
=======
        String name = courseBean.getClass_name();
>>>>>>> b079ae49aea3652b48f9c84201c89333c2f216f2
        courseholder.classname.setText(name);

        int i = courseBean.getClass_liked();
        String like = String.valueOf(i);
        courseholder.likesum.setText(like);

        String pic = courseBean.getClass_pic();
        if (!pic.equals(""))
            Picasso.with(context)
                    .load("http://10.0.2.2/YueJian16/Public/photo/"+pic)
                    .into(courseholder.classImag);

<<<<<<< HEAD
        final String vname = courseBean.getClass_video();
        final String intro = courseBean.getClass_intro();
        courseholder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, MaclassActivity.class);
                intent.putExtra("vname",vname);
                intent.putExtra("intro",intro);
                intent.putExtra("title",name);
                context.startActivity(intent);
            }
        });

=======
>>>>>>> b079ae49aea3652b48f9c84201c89333c2f216f2

    }

    @Override
    public int getItemCount() {
        return courseList.size();
    }
}
